import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { RewordItemCellRenderer } from "../../copy/RewordItemCellRenderer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
type int = number;
//class DelegateTaskDropList
    
    export  class DelegateTaskDropList /* flash.display.Sprite */
    {
        constructor()
        {
            
            var loc2=null;
            var loc1=0;
            while (loc1 < this._pagesize) 
            {
                loc2 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                loc2.x = loc1 * 39;
                loc2.y = 0;
                this.addChild(loc2);
                ++loc1;
            }
            this._rewardsList = ObjCreate.createTileList(0, 0, 390, 45, this);
            this._rewardsList.rowHeight = 38;
            this._rewardsList.columnWidth = 38;
            this._rewardsList.horizontalGap = 1;
            this._rewardsList.verticalGap = 1;
            this._rewardsList.setStyle("cellRenderer", RewordItemCellRenderer);
            this.addChild(this._rewardsList);
            this._rewardsDp = new DataProvider();
            this._rewardsList.dataProvider = this._rewardsDp;
            this._pageSelec = ObjCreate.createPageSelecter(150, 44, this);
            this._pageSelec.addEventListener(flash.events.Event.CHANGE, this.onPageChange);
            return;
        }

        public setRewardItems(arg1: Array<any>): void
        {
            this._rewardItems = arg1;
            this.updateRewordItems();
            return;
        }

        /* internal  */onPageChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateRewordItems();
            return;
        }

        /* internal  */updateRewordItems(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            if (this._rewardItems && this._rewardItems.length > 0) 
            {
                this._pageSelec.maxPage = Math.ceil(this._rewardItems.length / this._pagesize);
                loc1 = (this._pageSelec.currentPage - 1) * this._pagesize;
                loc2 = this._pageSelec.currentPage * this._pagesize > this._rewardItems.length ? this._rewardItems.length : this._pageSelec.currentPage * this._pagesize;
                loc3 = this._rewardItems.slice(loc1, loc2);
                this._rewardsDp.removeAll();
                this._rewardsDp.addItems(loc3);
            }
            else 
            {
                this._rewardsDp.removeAll();
            }
            this._rewardsList.dataProvider = this._rewardsDp;
            this._rewardsList.drawNow();
            return;
        }

        /* internal */ /* var */_rewardsDp: DataProvider;

        /* internal */ /* var */_rewardItems: Array<any>;

        /* internal */ /* var */_pagesize: int=10;

        /* internal */ /* var */_rewardsList: GTileList;

        /* internal */ /* var */_pageSelec: PageSelecter;
    }
